Replace XendDomainInfo.setStoreChannel with XendDomainInfo.closeStoreChannel.
authoremellor@ewan <emellor@ewan>
Sat, 17 Sep 2005 17:09:31 +0000 (18:09 +0100)
committeremellor@ewan <emellor@ewan>
Sat, 17 Sep 2005 17:09:31 +0000 (18:09 +0100)
setStoreChannel was only ever called with channel=None (implying that the
current channel would be closed) so the other code there was superfluous.

Signed-off-by: Ewan Mellor<ewan@xensource.com>
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/XendDomainInfo.py

index 4a890c7bba5f7c9c670943ec1b73491222cfab42..0c4f5aa05950f1d3bfd7d1eee1d0c45c231684b2 100644 (file)
@@ -83,7 +83,7 @@ def save(xd, fd, dominfo, live):
     if child.wait() != 0:
         raise XendError("xc_save failed: %s" % lasterr)
 
-    dominfo.setStoreChannel(None)
+    dominfo.closeStoreChannel()
     xd.domain_destroy(dominfo.domid)
     return None
 
index 564d6540019edb00f1b661578562bb3cd33c8332..330736700b1006f7ee8e0d51c20ed717ca6a674e 100644 (file)
@@ -348,15 +348,20 @@ class XendDomainInfo:
         self.store_mfn = ref
         self.storeDom("store/ring-ref", ref)
 
-    def setStoreChannel(self, channel):
-        if self.store_channel and self.store_channel != channel:
-            self.store_channel.close()
-        self.store_channel = channel
-        if channel:
-            port = channel.port1
-        else:
-            port = None
-        self.storeDom("store/port", None)
+
+    def closeStoreChannel(self):
+        """Close the store channel, if any.  Nothrow guarantee."""
+        
+        try:
+            if self.store_channel:
+                try:
+                    self.store_channel.close()
+                    self.removeDom("store/port")
+                finally:
+                    self.store_channel = None
+        except Exception, exn:
+            log.exception(exn)
+
 
     def setConsoleRef(self, ref):
         self.console_mfn = ref
@@ -763,8 +768,7 @@ class XendDomainInfo:
         """
         self.state = STATE_VM_TERMINATED
         self.release_devices()
-        if self.store_channel:
-            self.setStoreChannel(None)
+        self.closeStoreChannel()
         if self.console_channel:
             # notify processes using this console?
             try: